home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / MacTCP class library / MacTCP class headers / CMacTCPDriver.h < prev    next >
Text File  |  1992-10-26  |  6KB  |  164 lines

  1. /*
  2.  
  3.   CMacTCPDriver.h
  4.   Superclass:    CObject
  5.  
  6.      The MacTCP Driver implementation (Chapter 2, MacTCP Programmer's Guide).
  7.  
  8.   Copyright © NCSA, University of Illinois;    June 2, 1992
  9.   Eric Johnson, John Newlin and Igor Livshits
  10.   
  11.   This code may be used, modified, and distributed free of charge and obligation.
  12.   
  13. */
  14.  
  15. #define    _H_CMacTCPDriver                                //    Include this file only once
  16.  
  17. #include    <Devices.h>
  18.  
  19. #define    kDriverName            "\p.IPP"                //    MacTCP registers itself under this name
  20. #define kInProgress            1                                //    I/O in progress
  21. #define kUserCanceled        -1                            //    User canceled current action
  22. #define    kSynchronous        False                        //    For synchronous calls
  23. #define    kAsynchronous        True                        //    For asynchronous calls
  24. #define    kTimeOut                60                            //    One minute
  25. #define kDriverError        2622                        //    Messages to the user
  26. #define    kCantOpen                1                                //    Cannot open the MacTCP driver
  27.  
  28.                                                                                 //    MacTCP result codes (-23000 through -23049)
  29. #define kIPBadLapErr                        -23000        //    Bad network configuration
  30. #define kIPBadCnfgErr                        -23001        //    Bad IP configuration error
  31. #define kIPNoCnfgErr                        -23002        //    Missing IP or LAP configuration error
  32. #define kIPLoadErr                            -23003        //    Error in MacTCP load
  33. #define kIPBadAddr                            -23004        //    Error in getting address
  34. #define kConnectionClosing            -23005        //    Connection is closing
  35. #define kInvalidLength                    -23006        //    Invalid specified length
  36. #define kConnectionExists                -23007        //    Request conflicts with existing connection
  37. #define kConnectionDoesntExist    -23008        //    Connection does not exist
  38. #define kInsufficientResources    -23009        //    Insufficient resources to perform request
  39. #define kInvalidStreamPtr                -23010        //    Invalid stream pointer
  40. #define kStreamAlreadyOpen            -23011        //    This stream is already open
  41. #define kConnectionTerminated        -23012        //    Connection terminated
  42. #define kInvalidBufPtr                    -23013        //    Invalid buffer pointer
  43. #define kInvalidRDS                            -23014        //    Invalid read
  44. #define kInvalidWDS                            -23014        //    Invalid write
  45. #define kOpenFailed                            -23015        //    Open action failed
  46. #define kCommandTimeout                    -23016        //    Action took too long
  47. #define kDuplicateSocket                -23017        //    Duplicate socket
  48.                                                                                 //    Error codes from internal IP functions
  49. #define kIPDontFragErr                    -23032        //    Packet too large to send w/o fragmenting
  50. #define kIPDestDeadErr                    -23033        //    Destination not responding
  51. #define kIPNoFragMemErr                    -23036        //    No memory to send fragmented pkt
  52. #define kIPRouteErr                            -23037        //    Can't route packet off-net
  53.                                                                                 //    General errors
  54. #define kNameSyntaxErr                     -23041        //    Error in name specification
  55. #define kCacheFault                            -23042        //    Cache fault
  56. #define kNoResultProc                        -23043        //    Result routine not specified
  57. #define kNoNameServer                        -23044        //    No name server avaialable
  58. #define kAuthNameErr                        -23045        //    
  59. #define kNoAnsErr                                -23046        //    No answer
  60. #define kDNRErr                                    -23047        //    Dynamic Name Resolver error
  61. #define    kOutOfMemory                        -23048        //    Out of memory
  62.  
  63.  
  64. enum
  65. {                                                                                //    Command codes
  66.     UDPCreate= 20,
  67.     UDPRead,
  68.     UDPBfrReturn,
  69.     UDPWrite,
  70.     UDPRelease,
  71.     UDPMaxMTUSize,
  72.     
  73.     TCPCreate= 30,
  74.     TCPPassiveOpen,
  75.     TCPActiveOpen,
  76.     TCPSend= 34,
  77.     TCPNoCopyRcv,
  78.     TCPBfrReturn,
  79.     TCPRcv,
  80.     TCPClose,
  81.     TCPAbort,
  82.     TCPStatus,
  83.     TCPRelease= 42,
  84.     TCPGlobalInfo
  85. };
  86.  
  87. typedef unsigned short    tcp_port;                    //    TCP port (UNICOS 6 only likes the lower 15 bits)
  88. typedef unsigned char        byte;                            //    8 bits
  89. typedef unsigned char        b_8;                            //    An 8-bit quantity
  90. typedef unsigned short    b_16;                            //    A 6-bit quantity
  91. typedef unsigned long        b_32;                            //    A 32-bit quantity
  92. typedef b_32                        ip_addr;                    //    IP addresses are 32-bits
  93. typedef b_16                        ip_port;                    //    Port number / reference
  94.  
  95. typedef OSErr (*OSErrProcPtr)                            //    A function that returns an operating system error
  96.             ();
  97. typedef Ptr (*PtrProcPtr)                                    //    A function that returns a pointer to something
  98.             ();
  99. typedef Boolean (*BooleanProcPtr)                    //    A function that returns a true or false value
  100.             ();
  101. typedef void (*voidProcPtr)                                //    A pascal type procedure that returns nothing
  102.             ();
  103.  
  104. /*===---------------===*/
  105.  
  106. class CMacTCPDriver : public CObject
  107. Begin
  108. protected:
  109.     ParmBlkPtr            parameterBlock;                //    The parameter block for control routines
  110.     Size                        sizeOfParameters;            //    Size of our parameter block
  111.     OSErr                        itsLastError;                    //    Last error we encountered
  112.     short                        refNum;                                //    Reference for our driver
  113.     Boolean                    fAsynchronous;                //    Synchrounous or asynchronous
  114.     
  115. public:
  116.     OSErr    IMacTCPDriver                                        //    Initialize the driver
  117.             (    void                                                            //    No arguments
  118.             );
  119.             
  120.     void    Dispose                                                    //    Destroy the driver object
  121.             (    void                                                            //    No arguments
  122.             );
  123.             
  124.     virtual void    SendControlInfoToDriver    //    Send control information to the driver
  125.             (    void                                                            //    No arguments
  126.             );
  127.     virtual void    Process                                    //    Process current action (set by Control() )
  128.             (    void                                                            //    No arguments
  129.             );
  130.     virtual Boolean    Done                                    //    Is anything still in the queue?
  131.             (    void                                                            //    No arguments
  132.             );
  133.     virtual void    GetParameters                        //    Gets the current parameters
  134.             (    ParmBlkPtr*        duplicateParameters    //    A clone is copied here
  135.             );
  136.     virtual void    SetParameters                        //    Sets the current parameters
  137.             (    ParmBlkPtr            newParameters            //    New parameters to set
  138.             );
  139.     virtual void    SetMode                                    //    Sets control mode
  140.             (    Boolean                    mode                            //    Mode flag
  141.             );
  142.     virtual Boolean    GetMode                                //    Gets control mode
  143.             (    void                                                            //    No arguments
  144.             );
  145.             
  146. protected:
  147.     virtual void    MakeParameters                    //    Create the parameter block
  148.             (    void                                                            //    No arguments
  149.             );
  150.     virtual void    SetCompletionProc                //    Sets the completion routine
  151.             (    ProcPtr                    myRoutine                    //    What to call while waiting
  152.             );
  153.     
  154.     //    ***  Subclass must over-ride!  ***    //
  155.     virtual void Wait                                            //    Waits...
  156.             (    void                                                            //    No arguments
  157.             );
  158.     virtual void SetSizeOfParameters            //    Sets the size of the parameter block
  159.             (    void                                                            //    No arguments
  160.             );
  161. End;
  162.  
  163. /*===---------------===*/
  164. /*=====================*/